package com.potenza.training.interview.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.potenza.training.interview.dao.InterviewLogDao;
import com.potenza.training.interview.entity.InterviewLogEntity;
import com.potenza.training.interview.service.InterviewLogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("interviewLogService")
public class InterviewLogServiceImpl extends ServiceImpl<InterviewLogDao, InterviewLogEntity> implements InterviewLogService {

    @Autowired
    private InterviewLogDao interviewLogDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<InterviewLogEntity> page = this.page(
                new Query<InterviewLogEntity>().getPage(params),
                new QueryWrapper<InterviewLogEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<InterviewLogEntity>  findById(Integer id) {

        QueryWrapper<InterviewLogEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(InterviewLogEntity::getIdentificationBit,id);
        List<InterviewLogEntity> list = interviewLogDao.selectList(queryWrapper);
        return list;
    }

    @Override
    public InterviewLogEntity findByinvitationId(Integer id) {
        QueryWrapper<InterviewLogEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(InterviewLogEntity::getInvitationId,id);
        return interviewLogDao.selectOne(queryWrapper);
    }

}